<script type="text/html" template lay-done="layui.data.done(d);">
    <div class="layui-form coreshop-form layui-form-pane" lay-filter="LAY-app-CoreCmsPrinter-createForm" id="LAY-app-CoreCmsPrinter-createForm">

        <div class="layui-form-item">
            <label for="code" class="layui-form-label  layui-form-required">应用编码</label>
            <div class="layui-input-inline layui-inline-5">
                <select name="code" lay-verify="required|verifycode">
                    {{# layui.each(d.params.data.thirdPartyEquipment, function(index, item){ }}
                    <option value="{{ item.title }}">{{ item.title }}</option>
                    {{# }); }}
                </select>
            </div>
            <div class="layui-form-mid">
                目前只对接易联云，默认为易联云
            </div>
        </div>

        <div class="layui-form-item">
            <label for="name" class="layui-form-label  layui-form-required">应用名称</label>
            <div class="layui-input-inline layui-inline-5">
                <select name="name" lay-verify="required|verifyname">
                    {{# layui.each(d.params.data.thirdPartyEquipment, function(index, item){ }}
                    <option value="{{ item.description }}">{{ item.description }}</option>
                    {{# }); }}
                </select>
            </div>
            <div class="layui-form-mid">
                目前只对接易联云，默认为易联云
            </div>
        </div>

        <div class="layui-form-item">
            <label for="clientId" class="layui-form-label  layui-form-required">易联云应用id</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="clientId" lay-verType="tips" lay-verify="required|verifyclientId" class="layui-input" lay-reqText="请输入易联云应用id" placeholder="请输入易联云应用id" />
            </div>
            <div class="layui-form-mid">
                易联云自有应用Id
            </div>
        </div>

        <div class="layui-form-item">
            <label for="clientSecret" class="layui-form-label  layui-form-required">易联云应用密钥</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="clientSecret" lay-verType="tips" lay-verify="required|verifyclientSecret" class="layui-input" lay-reqText="请输入易联云应用密钥" placeholder="请输入易联云应用密钥" />
            </div>
            <div class="layui-form-mid">
                易联云自有应用密钥
            </div>
        </div>

        <div class="layui-form-item">
            <label for="machineCode" class="layui-form-label  layui-form-required">易联云终端号</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="machineCode" lay-verType="tips" lay-verify="required|verifymachineCode" class="layui-input" lay-reqText="请输入易联云终端号" placeholder="请输入易联云终端号" />
            </div>
            <div class="layui-form-mid">
                打印机背面终端号
            </div>
        </div>

        <div class="layui-form-item">
            <label for="msign" class="layui-form-label  layui-form-required">易联云终端密钥</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="msign" lay-verType="tips" lay-verify="required|verifymsign" class="layui-input" lay-reqText="请输入易联云终端密钥" placeholder="请输入易联云终端密钥" />
            </div>
            <div class="layui-form-mid">
                打印机背面密钥
            </div>
        </div>

        <div class="layui-form-item">
            <label for="printerName" class="layui-form-label  layui-form-required">打印机名称</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="printerName" lay-verType="tips" lay-verify="required|verifyprinterName" class="layui-input" lay-reqText="请输入打印机名称" placeholder="请输入打印机名称" />
            </div>
            <div class="layui-form-mid">
                自定义打印机名称
            </div>
        </div>

        <div class="layui-form-item">
            <label for="phone" class="layui-form-label  layui-form-required">联系电话</label>
            <div class="layui-input-inline layui-inline-5">
                <input name="phone" lay-verType="tips" lay-verify="required|verifyphone" class="layui-input" lay-reqText="请输入联系电话" placeholder="请输入联系电话" />
            </div>
            <div class="layui-form-mid">
                联系电话
            </div>
        </div>

        <div class="layui-form-item">
            <label for="isDefault" class="layui-form-label  layui-form-required">是否默认</label>
            <div class="layui-input-inline layui-inline-5">
                <input type="checkbox" lay-filter="switch" name="isDefault" lay-skin="switch" lay-text="开启|关闭">
            </div>
            <div class="layui-form-mid">
                所有打印机只允许一个默认
            </div>
        </div>

        <div class="layui-form-item">
            <label for="isOpen" class="layui-form-label  layui-form-required">是否开启</label>
            <div class="layui-input-inline layui-inline-5">
                <input type="checkbox" lay-filter="switch" name="isOpen" lay-skin="switch" lay-text="开启|关闭">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="storeId" class="layui-form-label  layui-form-required">绑定门店</label>
            <div class="layui-input-inline layui-inline-5">
                <select name="storeId" lay-verify="required|number">
                    <option value="0" selected="selected">全局使用</option>
                    {{# layui.each(d.params.data.stores, function(index, item){ }}
                    <option value="{{ item.id }}">{{ item.storeName }}</option>
                    {{# }); }}
                </select>
            </div>
            <div class="layui-form-mid">
                绑定后将走门店打印机
            </div>
        </div>

        <div class="layui-form-item text-right core-hidden">
            <input type="button" class="layui-btn" lay-submit lay-filter="LAY-app-CoreCmsPrinter-createForm-submit" id="LAY-app-CoreCmsPrinter-createForm-submit" value="确认添加">
        </div>
    </div>
</script>
<script>
    var debug = layui.setter.debug;
    layui.data.done = function (d) {
        //开启调试情况下获取接口赋值数据
        if (debug) { console.log(d.params.data); }
        layui.use(['admin', 'form', 'laydate', 'upload', 'coreHelper', 'cropperImg'],
            function () {
                var $ = layui.$
                    , form = layui.form
                    , admin = layui.admin
                    , laydate = layui.laydate
                    , upload = layui.upload
                    , cropperImg = layui.cropperImg
                    , coreHelper = layui.coreHelper;

                laydate.render({
                    elem: '#createTime-CoreCmsPrinter-expiressEndTime',
                    type: 'datetime'
                });
                laydate.render({
                    elem: '#createTime-CoreCmsPrinter-createTime',
                    type: 'datetime'
                });
                form.verify({

                    verifyname: [/^.{0,50}$/, '应用名称最大只允许输入50位字符'],
                    verifycode: [/^.{0,50}$/, '应用编码最大只允许输入50位字符'],
                    verifyclientId: [/^.{0,50}$/, '易联云应用id最大只允许输入50位字符'],
                    verifyclientSecret: [/^.{0,50}$/, '易联云应用密钥最大只允许输入50位字符'],
                    verifymachineCode: [/^.{0,50}$/, '易联云终端号最大只允许输入50位字符'],
                    verifymsign: [/^.{0,50}$/, '易联云终端密钥最大只允许输入50位字符'],
                    verifyprinterName: [/^.{0,50}$/, '打印机名称最大只允许输入50位字符'],
                    verifyphone: [/^.{0,50}$/, '联系电话最大只允许输入50位字符'],
                    verifyaccessToken: [/^.{0,50}$/, '访问令牌，API调用时需要，令牌可以重复使用无失效时间，请开发者全局保存最大只允许输入50位字符'],
                    verifyrefreshToken: [/^.{0,50}$/, '更新access_token所需，有效时间35天最大只允许输入50位字符'],
                });
                //重载form
                form.render(null, 'LAY-app-CoreCmsPrinter-createForm');
            })
    };
</script>
